﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter7.Section1
{
    public class Example01
    {
        public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double, double[]> ff
                = new V.Function.ToLastType<double, double[]>(func);
            V.Path c = new V.Path(ff);
            c.ParameterFrom = 0.0;
            c.ParameterTo = 2.0 * Math.PI;
            V.Function.ToLastType<double[], double> fff
                = new V.Function.ToLastType<double[], double>(f);
            V.PathIntegral obj = new V.PathIntegral(fff, c);
            obj.Compute();
            result += obj.Result.ToString() + "\r\n";

            double res = 2.0 * Math.Sqrt(2.0) 
                * Math.PI / 3.0 * (3.0 + 4.0 * Math.PI * Math.PI);
            result += res.ToString() + "\r\n";
        }
        private double[] func(double t)
        {
            double[] x = new double[3];
            x[0] = Math.Cos(t);
            x[1] = Math.Sin(t);
            x[2] = t;
            return x;
        }
        private double f(double[] x)
        {
            return x[0]*x[0]+x[1]*x[1]+x[2]*x[2];
        }
    }
}
/* 
125.817757876791
125.817757876244
*/

